<?php
/**
 * Created by PhpStorm.
 * user: songlintao
 * Date: 2017/8/24
 * Time: 下午2:59
 *
 * @param $var
 */
function p( $var ) {
	if ( is_bool( $var ) ) {
		var_dump( $var );
	} else if ( is_null( $var ) ) {
		var_dump( null );
	} else {
		echo '<pre style="border: solid red;background-color: aquamarine">' . print_r( $var, true ) . '</pre>';
	}
}

function D( $key, $default = null ) {
	@$ret = $_REQUEST[ $key ];
	if ( isset( $ret ) ) {
		return $ret;
	} else {
		return $default;
	}
}

function API( $code, $message, $datas ) {
	if ( ! $code ) {
		$code = 200;
	}
	if ( ! $message ) {
		$message = "success";
	}

	$body = [ 'code' => $code, 'message' => $message, 'datas' => $datas ];
	$body = json_encode( $body, JSON_UNESCAPED_UNICODE );
	echo $body;

}

function API_SUCCESS() {
	API( null, null, null );
}


function API_ERROR( $code, $message = '' ) {
	API( $code, $message, null );
}

